var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = process.env.PORT || 4000;
const os = require('os');
app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(socket){
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
  });
});
setInterval(function(){
  let data = {};
  data.cpus = os.cpus();
  data.freemem = os.freemem();
  data.time = new Date();
  data.totalmem = os.totalmem();
  io.emit('broadcast',data);
},1500)
http.listen(port, function(){
  console.log('listening on *:' + port);
});
